Page({
  data: {
    // 食物列表及对应的图片路径
    foodList: [
      { name: '火锅', image: '/images/sushi.jpg' },
      { name: '烧烤', image: '/images/sushi.jpg' },
      { name: '寿司', image: '/images/sushi.jpg' },
      { name: '披萨', image: '/images/sushi.jpg' },
      { name: '汉堡', image: '/images/sushi.jpg' },
      { name: '拉面', image: '/images/sushi.jpg' }
    ],
    recommendedFood: '',
    recommendedFoodImage: ''
  },
  onLoad() {
    // 初始化时不推荐食物和图片
    this.setData({
      recommendedFood: '',
      recommendedFoodImage: ''
    });
  },
  getRandomFood() {
    const { foodList } = this.data;
    const randomIndex = Math.floor(Math.random() * foodList.length);
    const randomFood = foodList[randomIndex];
    this.setData({
      recommendedFood: randomFood.name,
      recommendedFoodImage: randomFood.image
    });
  },
  // 跳转到 camera 页面
  navigateToCamera() {
    wx.navigateTo({
      url: '/pages/camera/camera'
    });
  },
  // 跳转到 snake 页面
  navigateToSnake() {
    wx.navigateTo({
      url: '/pages/snake/snake'
    });
  },
  // 跳转到 color 页面
  navigateToColor() {
    wx.navigateTo({
      url: '/pages/color/color'
    });
  }
});